package com.flink.api.unit9;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * union_stream_1
 *
 * @author caizhiyang
 * @since 2024-02-23
 */
public class union_stream_1 {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<Integer> ds1 = env.fromElements(1, 2, 3);
        DataStreamSource<Integer> ds2 = env.fromElements(2, 2, 3);
        DataStreamSource<String> ds3 = env.fromElements("2", "2", "3");

        //union要求流的数据类型必须一致
        ds1.union(ds2,ds3.map(Integer::valueOf)).print();
        env.execute();
    }
}
